var express = require('express');
var router = express.Router();
const mongoose = require("mongoose");
//表现层
//获取分页食品
const { getGoods2, addGoods2, getOne2, updateOne2, deleteOne2,getAllgoods2 } = require("../service/goodsService")
router.get('/getGoods', async(req, res, next)=>{
    res.send(await getGoods2(req.query));
});
//获取所有食品
router.get('/getAllgoods', async(req, res, next)=>{
    res.send(await getAllgoods2(req.query));
});


router.get('/:_id', async function (req, res, next) {
    res.send(await getOne2(req.params));
});


router.put('/', async (req, res, next) => {
    res.send(await updateOne2(req.body));
});
router.put('/deleteOne', async (req, res, next) => {
    res.send(await deleteOne2(req.body));
});

//添加食品
router.post('/', async (req, res, next) => {
    res.send(await addGoods2(req.body));
});





module.exports = router;
